<style scoped lang="scss">
  .bg {
    background: #ffffff;
    padding: 10px;
    border-radius: 6px;
  }

  .queryLabel {
    font-weight: bold;
    font-size: 16px;
    font-color: #464c5b;
    text-align: left;
    padding: 6px;
  }

  .queryInput {
    flex: 0 0 300px;
    border: 1px solid #57a3f3;
    border-radius: 4px;
  }

  .queryBtn {
    background: #57a3f3;
    margin: -6px -9px;
  }

  .queryGroupBtnContain {
    text-align: left;
    padding-top: 4px;
  }

  .navItem {
    padding: 6px;
    line-height: 30px;
  }

  .contentCol {
    border: 1px solid #f1eded;
    border-radius: 3px;
    height: 980px;
    width: 65%;
  }

  .cardItem {
    padding: 0;
    min-width: 300px;
    float: left;
    margin: 4px;
  }

  .padding5 {
    padding: 5px;
  }

  .itemContain {
    display: flex;

    .itemLeft {
      flex: 0 0 60px;

      .leftIcon {
        background: #f3a97f;
      }

      .leftText {
        font-size: 14px;
        color: #9ea7b4;
        padding: 0;
      }
    }

    .itemRight {
      flex: 1;
      border-left: 1px solid #eee;

      .rightItemContain {
        color: #9ea7b4;
        display: flex;
        justify-content: space-between;

        .rightNumber {
          color: #f3a97f
        }

        .rightIcon {
          padding-top: 4px;
        }
      }
    }
  }

  .treeContain {
    height: 980px;
    /* overflow-y: auto; */
    border-radius: 3px;
    border: 1px solid #f1eded;
    /* margin-right: 5px; */
    padding: 3px;
    margin-right: 10px;
  }

  .cardRow {
    margin: 4px;
    width: 350px;
    height: 200px;
    float: left;
    border: solid 1px #d7d7d7;
    border-radius: 4px;
  }

  .cardRow:hover {
    background: #f6f6f6;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.47);
  }

  .rowInfo {
    padding: 4px;
    height: 880px;
    overflow: auto;
  }

  .ivu-modal-header p {
    height: 30px;
  }

  /*放大设备卡片的弹窗样式 start*/
  #top-tool {
  }

  #card-content {
    display: flex;

    .card-img {
      width: 30%;
      border-right: 1px solid #d7d7d7;
      padding: 0 20px;

      .imgStyle {
        display: block;
        margin: 100px auto;
      }
    }

    .card-data {
      width: 70%;
      overflow: auto;
      height: 500px;
      padding: 0 20px;
      font-size: 18px;
    }
  }

  #card-foot {
    display: flex;
    justify-content: space-between;
    font-size: 16px;

    .iconn {
      color: #2d8cf0;
    }
  }
</style>
<template>
  <Row>
    <Card dis-hover>
      <!-- 搜索部分 -->
      <!--<div slot="title">
        <div class="queryLabel">空间管理</div>
        <Input v-model="queryObj.str" placeholder="请输入搜索内容" class="queryInput">
        <Button slot="append" icon="ios-search" type="info" class="queryBtn"> 搜索</Button>
        </Input>
        <div class="queryGroupBtnContain">
          <Button type="text">涂装</Button>
          <Button type="text">HD1</Button>
          <Button type="text">焊装</Button>
          <Button type="text">树脂</Button>
          <Button type="text">公用动力</Button>
          <Button type="text">总装</Button>
        </div>
      </div>-->
      <!-- 展示部分 -->
      <Row>
        <Col span="8" class="treeContain">
          <MyScroll>
            <Tree v-if="iviewtreeShow" :data="treeData" :render="renderContent"></Tree>
          </MyScroll>
          <Spin size="large" fix v-if="!iviewtreeShow"></Spin>
        </Col>
        <Col span="15" class="contentCol">
          <div class="navItem">
            <!--          <Row>-->
            <!--            <Col span="16">-->
            <Breadcrumb class="BreadcrumbContain" style="display: inline-block">
              <BreadcrumbItem v-for="(item,index) in queryNaviTextData" :key=" 'sd'+index ">{{item}}</BreadcrumbItem>
            </Breadcrumb>
            <!--            </Col>-->
            <!--            <Col span="8">-->
            <div class="rt">
              <Button type="success" icon="ios-add-circle-outline" @click.native="resetEngine()" :loading="loadingReset">重置引擎</Button>
              <Button type="success" icon="ios-add-circle-outline" @click.native="quickGenerateVirtualDevice()">新增虚拟设备</Button>
<!--              <Button type="success" icon="ios-add-circle-outline" @click.native="saveAdd()">新增设备</Button>-->
<!--              <Button type="success" icon="ios-add-circle-outline" @click.native="saveVirtual()">新增虚拟设备</Button>-->
<!--              <Button type="success" icon="ios-add-circle-outline" @click.native="saveGroup()">新增组合设备</Button>-->
            </div>
            <!--            </Col>-->
            <!--          </Row>-->
          </div>
          <Row class="rowInfo">
            <Col span="6" v-for="(item, index) in spaceDeviceData" :key="'sd'+index" class="cardRow">
              <!--组件化-->
              <DataCard :card-data="item" @scaleFull="scaleFull(item)" @enteringForm="enteringFormChild(item)"
                        @editForm="editFormChild(item)" @deleteDevFromSpace="deleteDevFromSpace(item)"></DataCard>
            </Col>
            <Spin size="large" fix v-if="spaceDeviceObj.isRequest && spaceDeviceData.length > 0"></Spin>
            <Alert type="warning" show-icon v-show="!spaceDeviceObj.hasData">无设备信息！
              <template slot="desc"></template>
            </Alert>
          </Row>
        </Col>
      </Row>
    </Card>
    <!--    点击放大弹窗来的 窗口-->
    <Modal v-model="cardModal" width="1500" :scrollable="true" @on-cancel="cancelFull">
      <p slot="header" id="top-tool">
        <span style="margin-right: 10px; font-size: 18px;"> id: {{scaleCardObj.id}}</span>
        <Button type="primary" @click="editForm" style="margin-right: 20px;">编辑</Button>
        <Button type="success" @click="enteringForm">录入</Button>
      </p>
      <div id="card-content">
        <div class="card-img">
          <img :src="preview" alt="" class="imgStyle">
          <Spin size="large" fix v-if="loadingImgStatus"></Spin>
        </div>
        <div class="card-data row-list">
          <Row v-for="(item, index) in properties" :key="index">
            <NumLine :did="scaleCardObj.id" :property="item" v-if="item.propertyType === 100"></NumLine>
            <ToggleLine :did="scaleCardObj.id" :property="item" v-if="item.propertyType === 101"></ToggleLine>
            <StatusLineGreen :did="scaleCardObj.id" :property="item" v-if="item.propertyType === 103"></StatusLineGreen>
            <StatusLineRed :did="scaleCardObj.id" :property="item" v-if="item.propertyType === 104"></StatusLineRed>
            <StatusLineYellow :did="scaleCardObj.id" :property="item" v-if="item.propertyType === 105"></StatusLineYellow>
          </Row>
        </div>
      </div>
      <div slot="footer" id="card-foot">
        <div class="footer-text">{{scaleCardObj.name}} | {{scaleCardObj.sn? scaleCardObj.sn : '无编号'}}</div>
        <div class="footer-star" style="cursor:pointer;" @click="clickStart(scaleCardObj)">
          <Icon type="ios-star" size="26" class="iconn" v-show="scaleCardObj.follow"></Icon>
          <Icon type="ios-star-outline" size="26" v-show="!scaleCardObj.follow"></Icon>
        </div>
      </div>
    </Modal>
    <!--真实设备modal-->
    <Modal v-model="modal1" :title="modalTitle" width="1700" :scrollable="true"
           @on-visible-change="modalChangeStatus">
      <Tabs v-model="showTabPanel" type="card">
        <TabPane name="oneTab" label="设备信息" class="padding5">
          <DeviceManageForm ref="refDeviceInfoForm" @showTab="showTab" @saveSubmitReady="saveSubmitReady"
                            @updSubmitReady="updSubmitReady"></DeviceManageForm>
        </TabPane>
        <TabPane name="twoTab" label="采集项" class="padding5">
          <CollectionForm ref="refDeviceColForm" @showTab="showTab" @saveSubmitReady="saveSubmitReady"
                          @updSubmitReady="updSubmitReady"></CollectionForm>
        </TabPane>
        <!--<TabPane name="threeTab" label="阀值设定" class="padding5">
          <LimitSetting ref="limitSetting"></LimitSetting>
        </TabPane>-->
        <TabPane name="fourTab" label="参数设定" class="padding5">
          <DevParams ref="devParams"></DevParams>
        </TabPane>
        <TabPane name="fiveTab" label="脚本代码" class="padding5">
          <ScriptPanel ref="refScript" @sonCallSave="callSonCalls"></ScriptPanel>
        </TabPane>
      </Tabs>
      <div slot="footer" style="text-align: center;">
        <Button type="primary" @click="callSave()" style="width: 300px;" :loading="saveDevLoading">保存</Button>
      </div>
    </Modal>
    <!--  真实设备 end  -->
    <!--虚拟设备弹窗 start-->
    <Modal v-model="modal2" :title="modalTitle2" width="1700" :scrollable="true"
           @on-visible-change="modalChangeStatus2" :mask-closable="false">
      <VirtualPanel ref="virs" @tell-refresh="doSonRefresh"></VirtualPanel>
      <!--<div slot="footer" style="display: none;"></div>-->
      <div slot="footer" style="text-align: center;">
        <Button type="primary" @click="doSaveVirtualObj" style="width: 300px;">保存数据</Button>
      </div>
    </Modal>
    <!--虚拟设备弹窗 end-->
    <!--    组合设备弹窗-->
    <Modal v-model="modal3" :title="modalTitle3" width="1700" :scrollable="true"
           @on-visible-change="modalChangeStatus" class="xsa" :mask-closable="false">
      <GroupDevice ref="groupDevice" @tell-refresh="doSonRefresh"></GroupDevice>
      <div slot="footer" style="display: none;"></div>
    </Modal>
    <!--录入数据弹窗-->
    <Modal v-model="modal4" :title="modalTitle4" width="1700" :scrollable="true"
           @on-visible-change="dataEntryModalChange" :mask-closable="false">
      <DataEntry ref="dataEntry" :into="dataEntryObj"></DataEntry>
      <div slot="footer" style="display: none;"></div>
    </Modal>
    <!--左侧Tree树的增加和编辑-->
    <Modal v-model="auModalObj.showModal" :title="auModalObj.modalTitle">
      <Form ref="formValidate" :model="formValidate" :label-width="80">
        <FormItem label="节点名称" prop="title">
          <Input v-model="formValidate.title" placeholder="请输入节点名称"></Input>
        </FormItem>
        <FormItem label="节点类型" prop="type">
          <Select v-model="formValidate.type">
            <Option v-for="item in spaceType" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
        </FormItem>
        <FormItem label="排序">
          <InputNumber :max="100" :min="1" v-model="formValidate.sort"></InputNumber>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click.native="auModalObj.noClick">取消</Button>
        <Button type="primary" @click.native="auModalObj.yesClick">确认</Button>
        <!-- :loading="modal_loading" -->
      </div>
    </Modal>
<!--    创建站房弹窗-->
    <Modal v-model="stationModal" title="创建站房">
      <RadioGroup v-model="stationInitValue" type="button" @on-change="stationTypeChange">
        <Radio label="制冷站房"></Radio>
        <Radio label="空压站房" disabled></Radio>
      </RadioGroup>
      <Form ref="formValidate" :model="coolStation" :label-width="80" style="margin-top: 20px;">
        <Row>
          <Col span="22">
            <FormItem label="站房名称" prop="title">
              <Input v-model="coolStation.name" placeholder="请输入站房名称"></Input>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="12">
            <FormItem label="制冷主机">
              <InputNumber :max="10" :min="1" v-model="coolStation.coolMain"></InputNumber>
            </FormItem>
          </Col>
          <Col span="12">
            <FormItem label="冷却泵">
              <InputNumber :max="10" :min="1" v-model="coolStation.coolPump"></InputNumber>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="12">
            <FormItem label="冷冻泵">
              <InputNumber :max="10" :min="1" v-model="coolStation.coldPump"></InputNumber>
            </FormItem>
          </Col>
          <Col span="12">
            <FormItem label="冷却塔">
              <InputNumber :max="10" :min="1" v-model="coolStation.coolTower"></InputNumber>
            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button type="text" @click.native="stationCancel">取消</Button>
        <Button type="primary" @click.native="stationCommit" :loading="stationCreatingLoading">确认</Button>
        <!-- :loading="modal_loading" -->
      </div>
    </Modal>
  </Row>
</template>
<script>
  import DataCard from '../modules/DataCard'
  import MyScroll from '../common/MyScroll.vue'
  import GroupDevice from '../device/manage/GroupDevice.vue'
  import VirtualPanel from '../device/manage/VirtualPanel.vue'
  import DeviceManageForm from '../device/manage/DeviceManageForm.vue'
  import CollectionForm from '../device/manage/CollectionForm.vue'
  import DevParams from '../device/manage/DevParams.vue'
  import ScriptPanel from '../device/type/ScriptPanel.vue'
  import StatusLineRed from '../modules/StatusLineRed'
  import StatusLineYellow from '../modules/StatusLineYellow'
  import StatusLineGreen from '../modules/StatusLineGreen'
  import NumLine from '../modules/NumLine'
  import ToggleLine from '../modules/ToggleLine'
  import DataEntry from '../device/manage/DataEntry.vue'

  export default {
    components: {
      DataCard,
      MyScroll,
      GroupDevice,
      VirtualPanel,
      DeviceManageForm,
      CollectionForm,
      DevParams,
      ScriptPanel,
      NumLine,
      ToggleLine,
      StatusLineRed,
      StatusLineYellow,
      StatusLineGreen,
      DataEntry
    },
    data: function () {
      let self = this
      // 新增or编辑节点
      let auModalObj = {
        showModal: false,
        modalTitle: '',
        show: function () {
          auModalObj.showModal = true
          return auModalObj
        },
        hide: function () {
          auModalObj.showModal = false
          return auModalObj
        },
        input: '',
        temFunc: function () {
        },
        yes: function (func) {
          auModalObj.temFunc = func
          return auModalObj
        },
        yesClick: function () {
          // self.$refs['formValidate'].validate((valid) => {
          //   if (valid) {
          //     // self.$Message.success('Success!')
          //     auModalObj.showModal = false
          //     auModalObj.temFunc()
          //     return auModalObj
          //   } else {
          //     self.$Message.error('Fail!')
          //   }
          // })
          // 如果是新建的话，并且判断是会否是站房，如果是则 自动创建三个子菜单，也许孙子菜单....
          if (self.formValidate.title === '') {
            self.$Message.error('请输入节点名称')
            return false
          } else {
            auModalObj.showModal = false
            auModalObj.temFunc()
            return auModalObj
          }
        },
        noClick: function () {
          auModalObj.showModal = false
          return auModalObj
        }
      }
      return {
        // 是否放大设备卡片弹框 start
        clickSpaceObj: null,
        cardModal: false,
        timer: 0,
        properties: [],
        scaleCardObj: {},
        loadingImgStatus: false,
        // 弹框内的图片
        preview: null,
        // end
        // 7月 24日 新增 需求
        modal4: false,
        modalTitle4: '录入设备数据',
        dataEntryObj: {}, // 录入设备数据，传入对象
        modal3: false,
        stationCreatingLoading: false,
        stationInitValue: '制冷站房',
        coolStation: {
          name: '',
          coolPump: 1,
          coldPump: 1,
          coolTower: 1,
          coolMain: 1
        },
        stationModal: false,
        loadingReset: false,
        modalTitle3: '',
        modal2: false,
        modalTitle2: '',
        modal1: false,
        modalTitle: '',
        showTabPanel: 'oneTab',
        editOneData: {},
        saveDevLoading: false,
        // end
        iviewtreeShow: false,
        rootTitle: '',
        pageIndex: 0,
        tableList: [],
        treeData: [],
        spaceType: [
          {'value': 1, 'label': '总部'},
          {'value': 2, 'label': '工厂'},
          {'value': 3, 'label': '车间'},
          {'value': 4, 'label': '生产线'},
          {'value': 12, 'label': '母排测温'},
          {'value': 13, 'label': '智能抄表'},
          {'value': 50, 'label': '空压站房(*)'},
          {'value': 51, 'label': '制冷站房(*)'},
          {'value': 52, 'label': '供水站房(*)'},
          {'value': 53, 'label': '供电站房(*)'},
          {'value': 54, 'label': '燃气站房(*)'},
          {'value': 55, 'label': '蒸汽站房(*)'},
          {'value': 100, 'label': '工艺监视'},
          {'value': 101, 'label': '工艺控制'},
          {'value': 102, 'label': '工艺能效'},
          {'value': 6, 'label': '机组(*)'},
          {'value': 7, 'label': '机房(*)'},
          {'value': 8, 'label': '车间管网(*)'},
          {'value': 9, 'label': '其他'},
          {'value': 10, 'label': '控制设备'},
          {'value': 11, 'label': '机组设备'}
        ],
        buttonProps: {
          type: 'ghost',
          size: 'small'
        },
        modalEditAdd: {
          show: false,
          title: ''
        },
        formValidate: {
          title: '',
          type: 1
        },
        // ruleValidate: {
        //   title: [{ required: true, message: '必填项！', trigger: 'blur' }, { max: 10, message: '最多10个字！', trigger: 'change' }],
        //   type: [{ required: true, message: '必填项！', trigger: 'change', type: 'number' }]
        // },
        temData: {},
        queryObj: {},
        itemObj: {},
        addItemObj: {},
        updateItemObj: {},
        auModalObj: auModalObj,
        queryNaviTextData: [],
        spaceDeviceData: [],
        spaceDeviceObj: {
          hasData: true,
          isRequest: true
        }
      }
    },
    created: function () {
      this.list()
    },
    mounted: function () {
      if (this.scaleCardObj.iotDevType) {
        if (this.scaleCardObj.iotDevType.iconUrl === null) {
          this.preview = require('../../assets/default_device.png')
          this.loadingImgStatus = false
        } else {
          this.askPic(this.scaleCardObj.iotDevType.iconUrl)
        }
      } else {
        this.preview = require('../../assets/default_device.png')
        this.loadingImgStatus = false
      }
    },
    destroyed: function () {
      this.$Message.destroy()
    },
    methods: {
      /* 7月30日 新增放大设备卡片的需求 */
      // 录入 的清空
      dataEntryModalChange (status) {
        if (!status) {
          // 退出modal，清空对象
          this.dataEntryObj = {}
          this.$refs.dataEntry.makeDefault()
          this.$refs.dataEntry.params = {
            sTime: '',
            eTime: '',
            selectProp: '',
            page: 0,
            size: 20
          }
        }
      },
      // 重置引擎
      resetEngine () {
        this.loadingReset = true
        window.myapi.do_get('/iot/dev/resetDevInfo').then(resp => {
          setTimeout(() => {
            this.loadingReset = false
          }, 2222)
        })
      },
      // 放大设备卡片的方法
      scaleFull (item) {
        this.cardModal = true
        this.scaleCardObj = item
        // 初始化，定时器 请求数据
        this.loadCurData(this.scaleCardObj.id)
        this.timer = setInterval(() => {
          this.loadCurData(this.scaleCardObj.id)
        }, Math.floor(Math.random() * 3000) + 2000)
      },
      loadCurData: function (id) {
        // 根据设备id 从 服务器获取实时数据  ---- 以此分发给 子显示组件
        let param = {id: id}
        window.myapi.cur_data(param).then(resp => {
          // console.log(resp)
          if (resp.status === 200 && resp.data.status === 200) {
            this.typeNum = resp.data.data.type
            // type为0是真实，type为1则是虚拟
            this.properties = resp.data.data.iotCollItemDatas
            /* if (resp.data.data.type === 0 || resp.data.data.type === 1) {
               this.properties = resp.data.data.iotCollItemDatas
             } else {
               this.properties = resp.data.data.virtualItems
             } */
          } else {
            this.$Notice.error({
              title: '服务器返回数据异常',
              desc: resp.data.msg
            })
          }
          // eslint-disable-next-line handle-callback-err
        }).catch((error) => {
          window.clearInterval(this.timer)
          this.$Notice.error({
            title: '返回数据异常！',
            desc: '数据异常, 已关闭请求数据, 请适时尝试刷新页面'
          })
        })
      },
      // 关闭放大设备卡片弹窗
      cancelFull () {
        // 清掉定时器
        window.clearInterval(this.timer)
      },
      // 编辑
      editForm () {
        // 点击编辑的公共方法
        this.editFormCommon(this.scaleCardObj)
      },
      // 录入
      enteringForm () {
        // 点击录入的公共方法
        this.enteringFormCommon(this.scaleCardObj)
      },
      // 编辑
      editFormChild (item) {
        // 点击编辑的公共方法
        this.editFormCommon(item)
      },
      // 录入
      enteringFormChild (item) {
        // 点击录入的公共方法
        this.enteringFormCommon(item)
      },
      // 删除设备
      deleteDevFromSpace (item) {
        let arr = []
        arr.push(item.id)
        window.myapi.dev_del(arr).then((res) => {
          if (res.data.status === 200) {
            this.$Notice.success({
              title: '提示',
              desc: `删除成功，刷新当前空间数据...`
            })
            this.spaceInfo(this.clickSpaceObj.id)
          } else {
            let msg = res.data.msg ? res.data.msg : '删除数据失败!'
            this.$Message.error(msg)
          }
        }).catch(function (e) {
          let msg = e.response.data.message ? e.response.data.message : '删除数据失败!'
          this.$Message.error({ duration: 0, closable: true, content: msg })
        })
      },
      // 点击编辑的公共方法
      editFormCommon (item) {
        this.editOneData = item
        let self = this
        if (item.type === 0) {
          self.editFull(item)
        } else if (item.type === 1) {
          self.$refs.virs.acceptEditData(item)
          self.modal2 = true
          self.modalTitle2 = '编辑虚拟设备'
        } else {
          self.$refs.groupDevice.acceptEditData(item)
          self.modal3 = true
          self.modalTitle3 = '编辑组合设备'
        }
      },
      // 编辑
      editFull (data) {
        this.modalTitle = '编辑真实设备'
        this.modal1 = true
        this.resetModalData()
        // 调用子组件，传值
        this.$refs.refDeviceInfoForm.updateFormdata(data)
        this.$refs.refDeviceColForm.updateFormdata(data)
        this.$refs.refScript.updateFormdata(data)
        // 暂时 注释 阀值设定的功能
        // this.$refs.limitSetting.refreshEditData(data)
        this.$refs.devParams.refreshEditData(data)
      },
      // 点击录入的公共方法
      enteringFormCommon (item) {
        console.log(item)
        this.dataEntryObj = JSON.parse(JSON.stringify(item))
        this.$refs.dataEntry.iotSpaceName = this.dataEntryObj.iotSpace ? this.dataEntryObj.iotSpace.name : ''
        this.$refs.dataEntry.params.devId = this.dataEntryObj.id
        // propsSelections
        if (this.dataEntryObj.type === 0) {
          this.$refs.dataEntry.propsSelections = this.dataEntryObj.iotDevType.iotCollItems
        } else {
          this.$refs.dataEntry.propsSelections = this.dataEntryObj.virtualItems
        }
        if (this.$refs.dataEntry.propsSelections.length > 0) {
          this.$refs.dataEntry.params.selectProp = this.$refs.dataEntry.propsSelections[0].name
          this.$refs.dataEntry.loadDatas()
        }
        this.modal4 = true
      },
      // end
      // 点击星星
      clickStart (obj) {
        let param = {'id': obj.id}
        if (obj.follow) {
          this.cancelFollow(param)
        } else {
          this.doFollow(param)
        }
      },
      // 弹框内的图片
      askPic (picUrl) {
        window.myapi.show_pic({url: picUrl}).then(resp => {
          this.preview = 'data:image/png;base64,' + btoa(
            new Uint8Array(resp.data)
              .reduce((data, byte) => data + String.fromCharCode(byte), '')
          )
        }).catch(info => {
          this.$Notice.warning({
            title: '操作提示',
            desc: info
          })
        }).finally((fin) => {
          this.loadingImgStatus = false
        })
      },
      // 点击关注
      doFollow: function (obj) {
        window.myapi.do_follow(obj).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.$Notice.success({
              title: '关注设备成功！',
              desc: ''
            })
            this.cardData.follow = true
          } else {
            this.$Notice.warning({
              title: resp.data.msg || '返回数据异常！',
              desc: ''
            })
          }
        }).catch(() => {
          this.$Message.error('数据异常')
        })
      },
      // 取消关注
      cancelFollow: function (obj) {
        window.myapi.cancel_follow(obj).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.$Notice.success({
              title: '已取消关注该设备！',
              desc: ''
            })
            this.cardData.follow = false
          } else {
            this.$Notice.error({
              title: '返回数据异常！'
            })
          }
        }).catch(() => {
          this.$Notice.error({
            title: '返回数据异常！'
          })
        })
      },
      /*
      * 7月24日 新增的需求
      * */
      // 新增组合设备的保存方法 start
      saveGroup () {
        this.$refs.groupDevice.loadDevDatas()
        this.modal3 = true
        this.modalTitle3 = '新增组合设备'
        this.$refs.groupDevice.setAllDefault()
      },
      // Modal2 和 Modal 3 的 方法 刷新方法
      doSonRefresh () {
        this.spaceInfo(this.editOneData.iotSpace.id)
        this.modal2 = false
        this.modal3 = false
      },
      listGroup () {
        let self = this
        let getData = {
          'size': self.pageObj.size,
          'page': self.pageObj.index,
          // 'iotDevType.brand_sn_name_commAddr_iotDevType.useType_iotSpace.name_plike': self.queryStr /* mkAlter */
          'keyword': self.queryStr /* mkAlter */
        }
        self.spinShow = true
        window.myapi.dev_list(getData).then(function (res) {
          self.tableList = []
          if (res.data.status === 200) {
            self.tableList = res.data.data.content
            self.totalElements = res.data.data.totalElements
            self.pageObj.size = res.data.data.size
            self.pageObj.total = res.data.data.totalElements
          } else {
            let msg = res.data.msg ? res.data.msg : '请求数据失败!'
            self.$Message.error({content: msg, duration: 5, closable: true})
          }
          self.spinShow = false
        }).catch(function (e) {
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '请求数据失败!'
            self.$Message.error({content: msg, duration: 5, closable: true})
            self.tableList = []
            self.spinShow = false
          }
        })
      },
      // 改变方法
      modalChangeStatus (status) {
        if (!status) {
          this.showTabPanel = 'oneTab'
          // this.$refs.limitSetting.limitList = []
          this.$refs.devParams.devParamsList = []
          // 清空 代码的填写
          this.$refs.refScript.makeDefault()
          // 清空组合设备
          this.$refs.groupDevice.setAllDefault()
          this.$refs.groupDevice.showTabPanel = 'aTab'
        }
      },
      // end
      // 新增虚拟设备的保存方法 start
      // 新增虚拟设备保存方法
      saveVirtual () {
        this.$refs.virs.loadDatas()
        this.modal2 = true
        this.modalTitle2 = '新增虚拟设备'
        this.$refs.virs.setAllDefault()
      },
      // 改变方法
      modalChangeStatus2 (status) {
        if (!status) {
          this.$refs.virs.setAllDefault()
        } else {
          this.$refs.virs.setDefaultDevType()
        }
      },
      doSaveVirtualObj () {
        // 保存或更新虚拟设备数据
        this.$refs.virs.doSave()
      },
      // end
      // 新增设备 start
      // 新增设备保存方法
      // 新增弹框
      saveAdd () {
        this.modalTitle = '新增真实设备'
        this.modal1 = true
        this.resetModalData()
        this.$refs.refDeviceInfoForm.updateFormdata({})
        this.$refs.refDeviceColForm.updateFormdata({})
        this.editOneData = {}
      },
      quickGenerateVirtualDevice () {
        // 一键创建当前空间下的虚拟设备
        if (!this.clickSpaceObj) {
          this.$Message.warning('未选择空间，不能创建空间....')
          return
        }

        this.$Modal.confirm({
          title: '操作确认',
          content: '<p>新建一个虚拟设备实体，正式的内容需要手动录入</p>',
          onOk: () => {
            let postData = {
              iotSpace: {id: this.clickSpaceObj.id},
              name: '请修改设备名称##',
              pic: '1999',
              sort: 1.11,
              type: 2,
              sn: this.generateUuid(10, 56),
              iotDevType: {id: 1}
            }

            window.myapi.dev_save(postData).then((res) => {
              if (res.data.status === 200) {
                // 加载当前空间的设备数据
                this.spaceInfo(this.clickSpaceObj.id)
              } else {
                let msg = res.data.msg ? res.data.msg : '保存失败！'
                this.$Message.error(msg)
              }
            }).catch(function (e) {
              let msg = e.response.data.message ? e.response.data.message : '保存失败!'
              this.$Message.error({ duration: 0, closable: true, content: msg })
            }).finally(() => {
            })
          },
          onCancel: () => {
          }
        })
      },
      generateUuid: function (len, radix) {
        let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
        let uuid = []
        radix = radix || chars.length

        if (len) {
          // Compact form
          for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]
        } else {
          // rfc4122, version 4 form
          let r

          // rfc4122 requires these characters
          uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
          uuid[14] = '4'

          for (let i = 0; i < 36; i++) {
            if (!uuid[i]) {
              r = 0 | Math.random() * 16
              uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r]
            }
          }
        }
        return uuid.join('')
      },
      resetModalData () {
        let self = this
        // document.querySelector('.ivu-modal-footer').style.display = 'none'
        self.childObj = {}
        sessionStorage.manageDeviceInfo = ''
        sessionStorage.manageDeviceCollection = ''
      },
      // 显示的tab
      showTab (chirldData) {
        let self = this
        if (chirldData.objStr) {
          // 存储form里面的数据
          let obj = JSON.parse(chirldData.objStr)
          self.childObj.name = obj.name
          self.childObj.model = obj.model
          self.childObj.sn = obj.sn
          self.childObj.commAddr = obj.commAddr
          self.childObj.readInterval = obj.readInterval
          self.childObj.iotSpace = obj.iotSpace
          self.childObj.iotDevType = obj.iotDevType
          self.childObj.iotDevType.iotCollItems.forEach((item) => {
            if (item.isGet === true || item.isGet === 'true') {
              item.isGet = 1
            } else {
              item.isGet = 0
            }
          })
          if (obj.debugStat) {
            self.childObj.debugStat = obj.debugStat
          }
          if (obj.id !== undefined) {
            self.childObj.id = obj.id
          }
        }
        /* if (chirldData.arrStr) {
          // 存储form里面的数据
          self.childObj.iotCollItems = chirldData.arrStr
        } */
        self.showTabPanel = chirldData.tab
      },
      // form弹窗
      updSubmitReady () {
        let self = this
        self.upd5()
      },
      // form弹窗
      saveSubmitReady () {
        let self = this
        self.save5()
      },
      // 新增真实设备保存方法
      callSave () {
        // 调用子组件 保存方法
        this.$refs.refDeviceInfoForm.saveDatasToDb('formValidate')
      },
      // 新增真实设备的 脚本代码
      callSonCalls () {
        this.$refs.refDeviceInfoForm.submitReady()
      },
      // 新增
      save5 () {
        let postData = this.childObj
        // 获取报警数据
        // postData.iotLimits = this.$refs.limitSetting.limitList
        // 获取参数
        postData.devParams = this.$refs.devParams.devParamsList
        // 获取脚本
        postData.scriptSwitch = this.$refs.refScript.scriptObj.switch
        postData.script = this.$refs.refScript.scriptObj.codes === '' ? '' : this.$refs.refScript.scriptObj.codes
        this.saveDevLoading = true
        window.myapi.dev_save(postData).then((res) => {
          if (res.data.status === 200) {
            this.$Message.success('保存成功!')
            this.modal1 = false
            this.resetModalData()
            // 新增后查询当前节点的 列表数据
            this.spaceInfo(this.editOneData.iotSpace.id)
          } else {
            let msg = res.data.msg ? res.data.msg : '保存失败！'
            this.$Message.error(msg)
          }
        }).catch(function (e) {
          let msg = e.response.data.message ? e.response.data.message : '保存失败!'
          this.$Message.error({duration: 0, closable: true, content: msg})
        }).finally(() => {
          this.saveDevLoading = false
        })
      },
      // 修改
      upd5 () {
        let postData = this.childObj
        // postData.iotLimits = this.$refs.limitSetting.limitList
        postData.devParams = this.$refs.devParams.devParamsList
        // 提取脚本数据
        postData.scriptSwitch = this.$refs.refScript.scriptObj.switch
        postData.script = this.$refs.refScript.scriptObj.codes === '' ? '' : this.$refs.refScript.scriptObj.codes
        this.saveDevLoading = true
        window.myapi.dev_upd(postData).then((res) => {
          if (res.data.status === 200) {
            this.$Message.success('保存成功!')
            this.modal1 = false
            this.resetModalData()
            // 编辑后查询当前节点的 列表数据
            this.spaceInfo(this.editOneData.iotSpace.id)
          } else {
            let msg = res.data.msg ? res.data.msg : '保存失败！'
            this.$Message.error(msg)
          }
        }).catch(function (e) {
          let msg = e.response.data.message ? e.response.data.message : '保存失败!'
          this.$Message.error({duration: 0, closable: true, content: msg})
        }).finally(() => {
          this.saveDevLoading = false
        })
      },
      // end
      // 渲染根节点
      renderRoot: function (h, {root, node, data}) {
        let self = this
        return h('span', {
          style: {
            display: 'inline-block',
            width: '100%'
          }
        }, [
          h('span', [
            h('Icon', {
              props: {
                type: 'ios-folder-outline'
              },
              style: {
                marginRight: '8px'
              }
            }),
            h('div', {
              style: {
                display: 'inline-block',
                borderRadius: '8px',
                border: '1px solid grey',
                fontSize: '8px',
                padding: '0 4px',
                color: 'grey'
              }
            }, data.id),
            h('span', {
              attrs: {
                class: 'ivu-tree-title'
              },
              on: {
                click: (event) => {
                  // 获取查询的级联导航
                  self.getNaviText(data)
                  // 选中样式
                  let oneNode = document.querySelector('.ivu-tree-title-selected')
                  if (oneNode) {
                    oneNode.classList.remove('ivu-tree-title-selected')
                  }
                  event.target.classList.add('ivu-tree-title-selected')
                }
              }
            }, data.title)
          ]),
          h('span', {
            style: {
              display: 'inline-block',
              float: 'right',
              marginRight: '32px'
            }
          }, [
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-add-circle',
                type: 'primary'
              }),
              style: {
                width: '60px',
                marginRight: '15px'
              },
              on: {
                click: () => {
                  // 创建站房
                  this.addStation(data)
                }
              }
            }),
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-add',
                type: 'primary'
              }),
              style: {
                width: '40px',
                marginRight: '5px'
              },
              on: {
                click: () => {
                  this.append(data)
                }
              }
            }),
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-refresh',
                type: 'primary'
              }),
              style: {
                width: '40px',
                marginRight: '0px'
              },
              on: {
                click: () => {
                  // 刷新树数据
                  this.list()
                }
              }
            })
          ])
        ])
      },
      // 渲染子节点
      renderContent: function (h, {root, node, data}) {
        let self = this
        if (data.title === self.rootTitle) {
          return this.renderRoot(h, {root, node, data})
        }
        return h('span', {
          style: {
            display: 'inline-block',
            width: '100%'
          }
        }, [
          h('span', [
            h('Icon', {
              props: {
                type: 'ios-paper-outline'
              },
              style: {
                marginRight: '8px'
              }
            }),
            h('div', {
              style: {
                display: 'inline-block',
                borderRadius: '8px',
                border: '1px solid grey',
                fontSize: '8px',
                padding: '0 4px',
                color: 'grey'
              }
            }, data.id),
            h('span', {
              attrs: {
                class: 'ivu-tree-title'
              },
              style: {
                verticalAlign: 'middle'
              },
              on: {
                click: (event) => {
                  // 获取查询的级联导航
                  self.getNaviText(data)
                  // 选中样式
                  let oneNode = document.querySelector('.ivu-tree-title-selected')
                  if (oneNode) {
                    oneNode.classList.remove('ivu-tree-title-selected')
                  }
                  event.target.classList.add('ivu-tree-title-selected')
                }
              }
            }, data.title)
          ]),
          h('span', {
            style: {
              display: 'inline-block',
              float: 'right',
              marginRight: '32px'
            }
          }, [
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-add',
                type: 'default'
              }),
              style: {
                marginRight: '8px'
              },
              on: {
                click: () => {
                  this.append(data)
                }
              }
            }),
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-remove',
                title: '删除',
                type: 'default'
              }),
              style: {
                marginRight: '8px'
              },
              on: {
                click: () => {
                  this.remove(root, node, data)
                }
              }
            }),
            h('Button', {
              props: Object.assign({}, this.buttonProps, {
                icon: 'md-create',
                type: 'default'
              }),
              on: {
                click: () => {
                  this.edit(data)
                }
              }
            })
          ])
        ])
      },
      addStation: function (data) {
        // 添加站房
        if (!this.clickSpaceObj || this.clickSpaceObj.type !== 2) {
          this.$Message.info('请选择工厂节点，再创建站房')
          return
        }
        this.stationInitValue = '制冷站房'
        this.coolStation = {
          coldPump: 1,
          coolMain: 1,
          coolPump: 1,
          coolTower: 1,
          name: ''
        }
        this.stationModal = true
      },
      stationTypeChange: function (data) {
        console.log('value...', data)
      },
      stationCancel: function () {
        this.stationModal = false
      },
      stationCommit: function () {
        if (!this.coolStation.name || this.coolStation.coolMain === 0) {
          this.$Message.info('请输入必要内容....')
          return
        }
        let json = {
          name: this.coolStation.name,
          type: 51,
          sort: 1,
          parentId: this.clickSpaceObj.id
        }
        this.stationCreatingLoading = true
        let url = 'iot/space/createCoolSystem?coolPump=' + this.coolStation.coolPump + '&coldPump=' + this.coolStation.coldPump + '&coolTower=' + this.coolStation.coolTower + '&coolMain=' + this.coolStation.coolMain
        window.myapi.post_json(url, json).then(res => {
          if (res.status === 200) {
            this.$Notice.success({
              title: '操作结果',
              desc: '创建成功，刷新空间数据.....'
            })
            this.list()
            this.stationCreatingLoading = false
            this.stationModal = false
          }
        }).finally(() => {
            this.stationCreatingLoading = false
            this.stationModal = false
        })
      },
      // 添加子节点
      append: function (data) {
        let self = this
        self.auModalObj.modalTitle = data.title + '新增节点'
        self.formValidate = {}
        self.formValidate.title = ''
        self.formValidate.type = data.type ? data.type + 1 : 1
        self.auModalObj.show().yes(function () {
          console.log(1)

          const children = data.children || []
          let title = self.formValidate.title
          children.push({
            title: title,
            expand: true
          })
          self.save(data, children, title)

          // self.$set(data, 'children', children)
        })
      },
      // 删除节点
      remove: function (root, node, data) {
        let self = this
        self.$Modal.confirm({
          title: data.title + '节点删除',
          content: '您确定删除节点：' + data.title + '，该操作会删除该空间下所有子级空间，以及设备数据，请谨慎操作....',
          onOk: () => {
            self.deleteMore(root, node, data)
          },
          okText: '确定',
          cancelText: '取消',
          onCancel: () => {
            this.$Message.info('取消删除')
          }
        })
      },
      // 编辑节点
      edit: function (data) {
        let self = this
        self.auModalObj.modalTitle = data.title + '编辑节点'
        self.formValidate = data
        self.auModalObj.show().yes(function () {
          let title = self.formValidate.title
          self.upd(data, title)
          // self.$set(data, 'title', title)
        })
      },
      // 获取树数据list
      list: function () {
        let self = this
        let getData = {
          'page': self.pageIndex,
          'searchParam': self.queryStr
        }
        self.tableList = []
        window.myapi.space_list(getData).then(function (res) {
          if (res.data.status === 200) {
            if (!res.data.data.content.length) {
              self.iviewtreeShow = true
              return false
            }
            self.tableList = res.data.data.content
            self.treeReady(res.data.data.content)
          } else {
            let msg = res.data.msg ? res.data.msg : '请求数据失败!'
            self.$Message.error({content: msg, duration: 5, closable: true})
          }
        }).catch(function (e) {
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '请求数据失败!'
            self.$Message.error({content: msg, duration: 5, closable: true})
          }
        })
      },
      // 树数据处理为标准格式
      treeReady: function (arr) {
        let self = this
        let one = self.treeRoot(arr)
        // 标准化的数据才不会有问题
        let standardOne = self.standardData(one)
        self.treeData = []
        self.treeData.push(standardOne)
        self.iviewtreeShow = true
      },
      // 提取树 根节点
      treeRoot: function (arr) {
        let self = this
        let len = arr.length
        for (let i = 0; i < len; i++) {
          if (arr[i].parentId === 0) {
            arr[i].children = []
            arr[i].title = arr[i].name
            arr[i].expand = true
            self.queryNaviTextData = []
            self.queryNaviTextData.push(arr[i].name)
            self.spaceInfo(arr[i].id)
            self.rootTitle = arr[i].name
            return self.treeNode(arr, arr[i])
          }
        }
      },
      // 提取树 子节点
      treeNode: function (arr, one) {
        let self = this
        let len = arr.length
        one.children = []
        for (let i = 0; i < len; i++) {
          if (one.id === arr[i].parentId) {
            arr[i].children = []
            arr[i].title = arr[i].name
            one.children.push(self.treeNode(arr, arr[i]))
          }
        }
        return one
      },
      // 把树数据标准化
      standardData: function (one) {
        let self = this
        let len = one.children.length
        let oneTem = {}
        oneTem.title = one.title
        oneTem.sort = one.sort
        // 设置节点是否展开
        if (one.parentId === 0 || one.type === 1 || one.type === 2 || one.type === 50 || one.type === 51 || one.type === 52) {
          oneTem.expand = true
        } else {
          oneTem.expand = false
        }
        oneTem.id = one.id
        oneTem.parentId = one.parentId
        oneTem.type = one.type
        oneTem.children = []
        for (let i = 0; i < len; i++) {
          oneTem.children.push(self.standardData(one.children[i]))
        }
        oneTem.children.sort((a, b) => {
          return a.sort - b.sort
        })
        return oneTem
      },
      // 重置form
      handleReset: function (name) {
        this.$refs[name].resetFields()
      },
      // 新增 节点
      save: function (data, children, title) {
        let self = this
        let postData = {
          name: title,
          type: this.formValidate.type,
          sort: this.formValidate.sort,
          parentId: data.id,
          remark: title
        }
        // eslint-disable-next-line no-unused-vars
        let url = '/iot/space/save2'
        if (postData.type > 49 && postData.type < 56) {
          url = url + '?ifBornSons=1'
        }
        if (postData.type === 6) {
          url = url + '?ifBornSons=2'
        }
        if (postData.type === 7) {
          url = url + '?ifBornSons=3'
        }
        if (postData.type === 8) {
          url = url + '?ifBornSons=4'
        }
        if (postData.type === 999) {
          url = url + '?ifBornSons=5'
        }
        window.myapi.put_post(url, postData, 'POST').then(function (res) {
          if (res.data.status === 200) {
            self.$Message.success('新增成功!')
            children.forEach((item) => {
              if (item.id === undefined || item.id === null || item.id === '') {
                item.id = res.data.data.id
              }
            })
            self.$set(data, 'children', children)
          } else {
            let msg = res.data.msg ? res.data.msg : '新增失败！'
            self.$Message.error(msg)
          }
        }).catch(function (e) {
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '新增失败!'
            self.$Message.error({duration: 0, closable: true, content: msg})
          }
        }).finally(() => {
          this.formValidate = {
            title: '',
            type: 1
          }
          // 更新缓存
          this.loadInitSpacesData()
          this.list()
        })
      },
      // 修改 节点
      upd: function (data, title) {
        let self = this
        let postData = {
          id: data.id,
          parentId: data.parentId,
          name: this.formValidate.title,
          remark: this.formValidate.remark,
          sort: this.formValidate.sort,
          type: this.formValidate.type
        }
        window.myapi.space_upd(postData).then(function (res) {
          if (res.data.status === 200) {
            self.$Message.success('修改成功!')
            self.$set(data, 'title', title)
          } else {
            let msg = res.data.msg ? res.data.msg : '修改失败！'
            self.$Message.error(msg)
          }
        }).catch(function (e) {
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '修改失败!'
            self.$Message.error({duration: 0, closable: true, content: msg})
          }
        }).finally(() => {
          // 更新缓存
          this.loadInitSpacesData()
        })
      },
      // 删除 节点
      deleteMore: function (root, node, data) {
        let self = this
        let postData = []
        postData.push(data.id)

        // 超级删除，空间下的设备都删除
        this.iviewtreeShow = false
        window.myapi.space_del_all(postData).then(res => {
          if (res.data.status === 200) {
            this.list()
            this.iviewtreeShow = true
          }
        }).finally(() => {
          this.iviewtreeShow = true
        })

        /* window.myapi.space_del(postData).then(function (res) {
          if (res.data.status === 200) {
            self.$Message.success('删除成功!')
            const parentKey = root.find(el => el === node).parent
            const parent = root.find(el => el.nodeKey === parentKey).node
            const index = parent.children.indexOf(data)
            parent.children.splice(index, 1)
          } else {
            let msg = res.data.msg ? res.data.msg : '删除失败!'
            self.$Message.error(msg)
          }
        }).catch(function (e) {
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '删除失败!'
            self.$Message.error({duration: 0, closable: true, content: msg})
          }
        }).finally(() => {
          // 更新缓存
          this.loadInitSpacesData()
        }) */
      },
      loadInitSpacesData () {
        // 加载空间数据
        window.myapi.space_tree().then(res => {
          if (res.data.status === 200) {
            this.$store.commit('user/addSpaces', res.data.data)
          } else {
            this.$Message.error(res.data.msg)
          }
        }).catch(function (e) {
          console.log('catch wrong ,,,,,,,,')
        })
      },
      // 查询单个实体 节点
      spaceInfo: function (id) {
        let self = this
        let postData = {'id': id}
        self.spaceDeviceObj.isRequest = true
        self.spaceDeviceData = []
        window.myapi.dev_sid(postData).then(function (res) {
          self.spaceDeviceObj.isRequest = false
          if (res.data.status === 200) {
            self.spaceDeviceData = res.data.data
            if (self.spaceDeviceData.length === 0) {
              self.spaceDeviceObj.hasData = false
            } else {
              self.spaceDeviceObj.hasData = true
            }
          } else {
            let msg = res.data.msg ? res.data.msg : '请求失败!'
            self.$Message.error(msg)
            self.spaceDeviceObj.hasData = false
          }
        }).catch(function (e) {
          self.spaceDeviceObj.isRequest = false
          if (e && e.response && e.response.data) {
            let msg = e.response.data.message ? e.response.data.message : '请求失败!'
            self.$Message.error({duration: 0, closable: true, content: msg})
            self.spaceDeviceObj.hasData = false
          }
        })
      },
      // 获取查询的导航
      getNaviText: function (data) {
        let self = this
        if (data.parentId === 0) {
          // 点击根节点
          self.queryNaviTextData = []
          self.queryNaviTextData.push(data.title)
        } else {
          // 子节点
          let txt = self.parentId2title(data.parentId)
          txt = txt.substring(0, txt.length - 1)
          let txtArr = txt.split(',')
          txtArr.reverse()
          txtArr.push(data.title)
          self.queryNaviTextData = txtArr
        }
        // 查询信息
        self.clickSpaceObj = data
        self.spaceInfo(data.id)
      },
      // parentId对应的title
      parentId2title: function (parentId) {
        let self = this
        let len = self.tableList.length
        for (let i = 0; i < len; i++) {
          if (parentId.toString() === self.tableList[i].id.toString()) {
            return self.tableList[i].title + ',' + self.parentId2title(self.tableList[i].parentId)
          }
        }
        return ''
      }
    },
    beforeDestroy () {
      // 销毁函数---- 执行收尾工作  cur_data
      window.clearInterval(this.timer)
    }
  }

</script>
